package com.kefu.chat.vo;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.kefu.chat.model.ChatMenuConfig;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractInsertVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@Data
public class ChatMenuConfigInsertVo extends AbstractInsertVo<ChatMenuConfig> {
    @ApiModelProperty(value = "是否展示图标0=否，1=是")
    private Integer showIcon;

    @NotEmpty
    @ApiModelProperty(value = "菜单名称")
    private String menuName;

    @NotNull
    @ApiModelProperty(name = "menuType", value = "菜单类型 发送消息=0，转人工=1，触发知识库=2，结束会话=3，满意度评价=4，留言=5，跳转链接=6")
    private Integer menuType;

    @ApiModelProperty(value = "消息内容")
    private String msgText;

    @TableField(value="label_link")
    @ApiModelProperty(value = "跳转地址")
    private String labelLink;

    @ApiModelProperty(value = "标准问题")
    private String docQuestion;

    @ApiModelProperty(value = "机器人id")
    private String robotId;

    @ApiModelProperty(name = "robotNo")
    private Integer robotNo;

    @ApiModelProperty(name = "docPattern", value = "模式：0单轮问题，1多轮问题")
    private Integer docPattern;

    @Override
    public ChatMenuConfig convert() {
        KefuContext context = KefuContext.getKefuContext();
        ChatMenuConfig info = BeanUtil.toBean(this, ChatMenuConfig.class);
        info.setUpdateTime(context.getNow());
        info.setCreateTime(context.getNow());
        info.setCreateUser(context.getUserId());
        info.setUpdateUser(context.getUserId());
        info.setCreateName(context.getUserName());
        info.setUpdateName(context.getUserName());
        info.setTenantId(context.getTenantId());
        return info;
    }
}
